package com.ksyun.start.camp.controller;

import com.ksyun.start.camp.model.ApiResponse;
import com.ksyun.start.camp.model.LogInstance;
import com.ksyun.start.camp.service.LoggingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 实现日志服务 API
 */
@RestController
@RequestMapping("/api")
public class ServiceController {


    @Autowired
    private LoggingService loggingService;

    @PostMapping("/logging")
    public ApiResponse log(@RequestBody LogInstance logInfo) {
        return loggingService.log(logInfo);
    }

    @GetMapping("/list")
    public ApiResponse<List<LogInstance>> getLogs(@RequestParam(required = false) String service) {
        return loggingService.getLogs(service);
    }
}
